<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The University of Glasgow, 1997-2006


Buffers for scanning string input stored in external arrays.
-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# LANGUAGE BangPatterns, CPP, MagicHash, UnboxedTuples #-}</span><span>
</span><span id="line-10"></span><span class="hs-pragma">{-# OPTIONS_GHC -O2 #-}</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- We always optimise this, otherwise performance of a non-optimised</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- compiler is severely affected</span><span>
</span><span id="line-13"></span><span>
</span><span id="line-14"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Data.StringBuffer</span><span>
</span><span id="line-15"></span><span>       </span><span class="hs-special">(</span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier">StringBuffer</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>        </span><span class="hs-comment">-- non-abstract for vs\/HaskellService</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span>         </span><span class="annot"><span class="hs-comment">-- * Creation\/destruction</span></span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#hGetStringBuffer"><span class="hs-identifier">hGetStringBuffer</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#hGetStringBufferBlock"><span class="hs-identifier">hGetStringBufferBlock</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#hPutStringBuffer"><span class="hs-identifier">hPutStringBuffer</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#appendStringBuffers"><span class="hs-identifier">appendStringBuffers</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#stringToStringBuffer"><span class="hs-identifier">stringToStringBuffer</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Inspection</span></span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#nextChar"><span class="hs-identifier">nextChar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#currentChar"><span class="hs-identifier">currentChar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#prevChar"><span class="hs-identifier">prevChar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#atEnd"><span class="hs-identifier">atEnd</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Moving and comparison</span></span><span>
</span><span id="line-33"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#stepOn"><span class="hs-identifier">stepOn</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#offsetBytes"><span class="hs-identifier">offsetBytes</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#byteDiff"><span class="hs-identifier">byteDiff</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#atLine"><span class="hs-identifier">atLine</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Conversion</span></span><span>
</span><span id="line-39"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#lexemeToString"><span class="hs-identifier">lexemeToString</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#lexemeToFastString"><span class="hs-identifier">lexemeToFastString</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#decodePrevNChars"><span class="hs-identifier">decodePrevNChars</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span>         </span><span class="annot"><span class="hs-comment">-- * Parsing integers</span></span><span>
</span><span id="line-44"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#parseUnsignedInteger"><span class="hs-identifier">parseUnsignedInteger</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Checking for bi-directional format characters</span></span><span>
</span><span id="line-47"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#containsBidirectionalFormatChar"><span class="hs-identifier">containsBidirectionalFormatChar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-48"></span><span>        </span><span class="annot"><a href="GHC.Data.StringBuffer.html#bidirectionalFormatChars"><span class="hs-identifier">bidirectionalFormatChars</span></a></span><span>
</span><span id="line-49"></span><span>        </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Encoding.html"><span class="hs-identifier">GHC.Utils.Encoding</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.IO.Unsafe.html"><span class="hs-identifier">GHC.Utils.IO.Unsafe</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Panic.Plain.html"><span class="hs-identifier">GHC.Utils.Panic.Plain</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-60"></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.Unsafe.html#"><span class="hs-identifier">System.IO.Unsafe</span></a></span><span>         </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Unsafe.html#unsafePerformIO"><span class="hs-identifier">unsafePerformIO</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Encoding.UTF8.html#"><span class="hs-identifier">GHC.IO.Encoding.UTF8</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Encoding.UTF8.html#mkUTF8"><span class="hs-identifier">mkUTF8</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Encoding.Failure.html#"><span class="hs-identifier">GHC.IO.Encoding.Failure</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Encoding.Failure.html#CodingFailureMode"><span class="hs-identifier">CodingFailureMode</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Encoding.Failure.html#IgnoreCodingFailure"><span class="hs-identifier">IgnoreCodingFailure</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exts.html#"><span class="hs-identifier">GHC.Exts</span></a></span><span>
</span><span id="line-69"></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.html#"><span class="hs-identifier">Foreign</span></a></span><span class="hs-cpp">
#if MIN_VERSION_base(4,15,0)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#"><span class="hs-identifier">GHC.ForeignPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier">unsafeWithForeignPtr</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-identifier">unsafeWithForeignPtr</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ForeignPtr</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">b</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">b</span><span>
</span><span id="line-75"></span><span class="hs-identifier">unsafeWithForeignPtr</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">withForeignPtr</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-78"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-79"></span><span class="hs-comment">-- The StringBuffer type</span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span class="hs-comment">-- |A StringBuffer is an internal pointer to a sized chunk of bytes.</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- The bytes are intended to be *immutable*.  There are pure</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- operations to read the contents of a StringBuffer.</span><span>
</span><span id="line-84"></span><span class="hs-comment">--</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- A StringBuffer may have a finalizer, depending on how it was</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- obtained.</span><span>
</span><span id="line-87"></span><span class="hs-comment">--</span><span>
</span><span id="line-88"></span><span class="hs-keyword">data</span><span> </span><span id="StringBuffer"><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-var">StringBuffer</span></a></span></span><span>
</span><span id="line-89"></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="StringBuffer"><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-var">StringBuffer</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-90"></span><span>     </span><span id="buf"><span class="annot"><span class="annottext">StringBuffer -&gt; ForeignPtr Word8
</span><a href="GHC.Data.StringBuffer.html#buf"><span class="hs-identifier hs-var hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-91"></span><span>     </span><span id="len"><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#len"><span class="hs-identifier hs-var hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">,</span><span>        </span><span class="hs-comment">-- length</span><span>
</span><span id="line-92"></span><span>     </span><span id="cur"><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#cur"><span class="hs-identifier hs-var hs-var">cur</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>         </span><span class="hs-comment">-- current pos</span><span>
</span><span id="line-93"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-94"></span><span>  </span><span class="hs-comment">-- The buffer is assumed to be UTF-8 encoded, and furthermore</span><span>
</span><span id="line-95"></span><span>  </span><span class="hs-comment">-- we add three @\'\\0\'@ bytes to the end as sentinels so that the</span><span>
</span><span id="line-96"></span><span>  </span><span class="hs-comment">-- decoder doesn't have to check for overflow at every single byte</span><span>
</span><span id="line-97"></span><span>  </span><span class="hs-comment">-- of a multibyte sequence.</span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680783033"><span id="local-6989586621680783035"><span class="annot"><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-100"></span><span>        </span><span id="local-6989586621680783029"><span class="annot"><span class="annottext">showsPrec :: Int -&gt; StringBuffer -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showsPrec"><span class="hs-identifier hs-var hs-var hs-var hs-var">showsPrec</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680783027"><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680783027"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&lt;stringbuffer(&quot;</span></span><span>
</span><span id="line-101"></span><span>                      </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; ShowS
forall a. Show a =&gt; a -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#shows"><span class="hs-identifier hs-var">shows</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#len"><span class="hs-identifier hs-var hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680783027"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;,&quot;</span></span><span> </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; ShowS
forall a. Show a =&gt; a -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#shows"><span class="hs-identifier hs-var">shows</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#cur"><span class="hs-identifier hs-var hs-var">cur</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680783027"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span>                      </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;)&gt;&quot;</span></span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-105"></span><span class="hs-comment">-- Creation / Destruction</span><span>
</span><span id="line-106"></span><span>
</span><span id="line-107"></span><span class="hs-comment">-- | Read a file into a 'StringBuffer'.  The resulting buffer is automatically</span><span>
</span><span id="line-108"></span><span class="hs-comment">-- managed by the garbage collector.</span><span>
</span><span id="line-109"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#hGetStringBuffer"><span class="hs-identifier hs-type">hGetStringBuffer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span>
</span><span id="line-110"></span><span id="hGetStringBuffer"><span class="annot"><span class="annottext">hGetStringBuffer :: String -&gt; IO StringBuffer
</span><a href="GHC.Data.StringBuffer.html#hGetStringBuffer"><span class="hs-identifier hs-var hs-var">hGetStringBuffer</span></a></span></span><span> </span><span id="local-6989586621680783022"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680783022"><span class="hs-identifier hs-var">fname</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-111"></span><span>   </span><span id="local-6989586621680783021"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680783021"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IOMode -&gt; IO Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#openBinaryFile"><span class="hs-identifier hs-var">openBinaryFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680783022"><span class="hs-identifier hs-var">fname</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#ReadMode"><span class="hs-identifier hs-var">ReadMode</span></a></span><span>
</span><span id="line-112"></span><span>   </span><span id="local-6989586621680783018"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680783018"><span class="hs-identifier hs-var">size_i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Integer
</span><a href="../../base/src/GHC.IO.Handle.html#hFileSize"><span class="hs-identifier hs-var">hFileSize</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680783021"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-113"></span><span>   </span><span id="local-6989586621680783016"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680783016"><span class="hs-identifier hs-var">offset_i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Integer -&gt; Integer -&gt; IO Integer
</span><a href="GHC.Data.StringBuffer.html#skipBOM"><span class="hs-identifier hs-var">skipBOM</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680783021"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680783018"><span class="hs-identifier hs-var">size_i</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span>  </span><span class="hs-comment">-- offset is 0 initially</span><span>
</span><span id="line-114"></span><span>   </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680783010"><span class="annot"><span class="annottext">size :: Int
</span><a href="#local-6989586621680783010"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Integer -&gt; Int) -&gt; Integer -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680783018"><span class="hs-identifier hs-var">size_i</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680783016"><span class="hs-identifier hs-var">offset_i</span></a></span><span>
</span><span id="line-115"></span><span>   </span><span id="local-6989586621680783009"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680783009"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr Word8)
forall a. Storable a =&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="../../base/src/Foreign.ForeignPtr.Imp.html#mallocForeignPtrArray"><span class="hs-identifier hs-var">mallocForeignPtrArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680783010"><span class="hs-identifier hs-var">size</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span class="hs-special">)</span><span>
</span><span id="line-116"></span><span>   </span><span class="annot"><span class="annottext">ForeignPtr Word8
-&gt; (Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680783009"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer)
-&gt; (Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680783006"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680783006"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-117"></span><span>     </span><span id="local-6989586621680783005"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680783005"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680783010"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Ptr Word8 -&gt; Int -&gt; IO Int
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO Int
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hGetBuf"><span class="hs-identifier hs-var">hGetBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680783021"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680783006"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680783010"><span class="hs-identifier hs-var">size</span></a></span><span>
</span><span id="line-118"></span><span>     </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680783021"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-119"></span><span>     </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680783005"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680783010"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-120"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">IOError -&gt; IO StringBuffer
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; IOError
</span><a href="../../base/src/GHC.IO.Exception.html#userError"><span class="hs-identifier hs-var">userError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;short read of file&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-121"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO StringBuffer
</span><a href="GHC.Data.StringBuffer.html#newUTF8StringBuffer"><span class="hs-identifier hs-var">newUTF8StringBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680783009"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680783006"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680783010"><span class="hs-identifier hs-var">size</span></a></span><span>
</span><span id="line-122"></span><span>
</span><span id="line-123"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#hGetStringBufferBlock"><span class="hs-identifier hs-type">hGetStringBufferBlock</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span>
</span><span id="line-124"></span><span id="hGetStringBufferBlock"><span class="annot"><span class="annottext">hGetStringBufferBlock :: Handle -&gt; Int -&gt; IO StringBuffer
</span><a href="GHC.Data.StringBuffer.html#hGetStringBufferBlock"><span class="hs-identifier hs-var hs-var">hGetStringBufferBlock</span></a></span></span><span> </span><span id="local-6989586621680782998"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782998"><span class="hs-identifier hs-var">handle</span></a></span></span><span> </span><span id="local-6989586621680782997"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782997"><span class="hs-identifier hs-var">wanted</span></a></span></span><span>
</span><span id="line-125"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621680782996"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782996"><span class="hs-identifier hs-var">size_i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Integer
</span><a href="../../base/src/GHC.IO.Handle.html#hFileSize"><span class="hs-identifier hs-var">hFileSize</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782998"><span class="hs-identifier hs-var">handle</span></a></span><span>
</span><span id="line-126"></span><span>         </span><span id="local-6989586621680782995"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782995"><span class="hs-identifier hs-var">offset_i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Integer
</span><a href="../../base/src/GHC.IO.Handle.html#hTell"><span class="hs-identifier hs-var">hTell</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782998"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">IO Integer -&gt; (Integer -&gt; IO Integer) -&gt; IO Integer
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Integer -&gt; Integer -&gt; IO Integer
</span><a href="GHC.Data.StringBuffer.html#skipBOM"><span class="hs-identifier hs-var">skipBOM</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782998"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782996"><span class="hs-identifier hs-var">size_i</span></a></span><span>
</span><span id="line-127"></span><span>         </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680782988"><span class="annot"><span class="annottext">size :: Int
</span><a href="#local-6989586621680782988"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-identifier hs-var">min</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782997"><span class="hs-identifier hs-var">wanted</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Integer -&gt; Int) -&gt; Integer -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782996"><span class="hs-identifier hs-var">size_i</span></a></span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782995"><span class="hs-identifier hs-var">offset_i</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-128"></span><span>         </span><span id="local-6989586621680782986"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782986"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr Word8)
forall a. Storable a =&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="../../base/src/Foreign.ForeignPtr.Imp.html#mallocForeignPtrArray"><span class="hs-identifier hs-var">mallocForeignPtrArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782988"><span class="hs-identifier hs-var">size</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span class="hs-special">)</span><span>
</span><span id="line-129"></span><span>         </span><span class="annot"><span class="annottext">ForeignPtr Word8
-&gt; (Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782986"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer)
-&gt; (Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680782985"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782985"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-130"></span><span>             </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621680782984"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782984"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782988"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Ptr Word8 -&gt; Int -&gt; IO Int
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO Int
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hGetBuf"><span class="hs-identifier hs-var">hGetBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782998"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782985"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782988"><span class="hs-identifier hs-var">size</span></a></span><span>
</span><span id="line-131"></span><span>                </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782984"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782988"><span class="hs-identifier hs-var">size</span></a></span><span>
</span><span id="line-132"></span><span>                   </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">IOError -&gt; IO StringBuffer
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; IOError
</span><a href="../../base/src/GHC.IO.Exception.html#userError"><span class="hs-identifier hs-var">userError</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; IOError) -&gt; String -&gt; IOError
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;short read of file: &quot;</span></span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span class="annot"><span class="annottext">(Int, Int, Integer, Handle) -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782984"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782988"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782996"><span class="hs-identifier hs-var">size_i</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782998"><span class="hs-identifier hs-var">handle</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-133"></span><span>                   </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO StringBuffer
</span><a href="GHC.Data.StringBuffer.html#newUTF8StringBuffer"><span class="hs-identifier hs-var">newUTF8StringBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782986"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782985"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782988"><span class="hs-identifier hs-var">size</span></a></span><span>
</span><span id="line-134"></span><span>
</span><span id="line-135"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#hPutStringBuffer"><span class="hs-identifier hs-type">hPutStringBuffer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-136"></span><span id="hPutStringBuffer"><span class="annot"><span class="annottext">hPutStringBuffer :: Handle -&gt; StringBuffer -&gt; IO ()
</span><a href="GHC.Data.StringBuffer.html#hPutStringBuffer"><span class="hs-identifier hs-var hs-var">hPutStringBuffer</span></a></span></span><span> </span><span id="local-6989586621680782982"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782982"><span class="hs-identifier hs-var">hdl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span id="local-6989586621680782981"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782981"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span id="local-6989586621680782980"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782980"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span id="local-6989586621680782979"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782979"><span class="hs-identifier hs-var">cur</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-137"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Any -&gt; (Ptr Any -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; ForeignPtr Any
forall a b. ForeignPtr a -&gt; Int -&gt; ForeignPtr b
</span><a href="../../base/src/GHC.ForeignPtr.html#plusForeignPtr"><span class="hs-identifier hs-var">plusForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782981"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782979"><span class="hs-identifier hs-var">cur</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((Ptr Any -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr Any -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680782977"><span class="annot"><span class="annottext">Ptr Any
</span><a href="#local-6989586621680782977"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-138"></span><span>          </span><span class="annot"><span class="annottext">Handle -&gt; Ptr Any -&gt; Int -&gt; IO ()
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutBuf"><span class="hs-identifier hs-var">hPutBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782982"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Any
</span><a href="#local-6989586621680782977"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782980"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-139"></span><span>
</span><span id="line-140"></span><span class="hs-comment">-- | Skip the byte-order mark if there is one (see #1744 and #6016),</span><span>
</span><span id="line-141"></span><span class="hs-comment">-- and return the new position of the handle in bytes.</span><span>
</span><span id="line-142"></span><span class="hs-comment">--</span><span>
</span><span id="line-143"></span><span class="hs-comment">-- This is better than treating #FEFF as whitespace,</span><span>
</span><span id="line-144"></span><span class="hs-comment">-- because that would mess up layout.  We don't have a concept</span><span>
</span><span id="line-145"></span><span class="hs-comment">-- of zero-width whitespace in Haskell: all whitespace codepoints</span><span>
</span><span id="line-146"></span><span class="hs-comment">-- have a width of one column.</span><span>
</span><span id="line-147"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#skipBOM"><span class="hs-identifier hs-type">skipBOM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span>
</span><span id="line-148"></span><span id="skipBOM"><span class="annot"><span class="annottext">skipBOM :: Handle -&gt; Integer -&gt; Integer -&gt; IO Integer
</span><a href="GHC.Data.StringBuffer.html#skipBOM"><span class="hs-identifier hs-var hs-var">skipBOM</span></a></span></span><span> </span><span id="local-6989586621680782975"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782975"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621680782974"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782974"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span id="local-6989586621680782973"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782973"><span class="hs-identifier hs-var">offset</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-149"></span><span>  </span><span class="hs-comment">-- Only skip BOM at the beginning of a file.</span><span>
</span><span id="line-150"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782974"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782973"><span class="hs-identifier hs-var">offset</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span>
</span><span id="line-151"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-152"></span><span>      </span><span class="hs-comment">-- Validate assumption that handle is in binary mode.</span><span>
</span><span id="line-153"></span><span>      </span><span class="hs-identifier">ASSERTM</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">hGetEncoding</span><span> </span><span class="hs-identifier">h</span><span> </span><span class="hs-operator">&gt;&gt;=</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-identifier">isNothing</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-154"></span><span>      </span><span class="hs-comment">-- Temporarily select utf8 encoding with error ignoring,</span><span>
</span><span id="line-155"></span><span>      </span><span class="hs-comment">-- to make `hLookAhead` and `hGetChar` return full Unicode characters.</span><span>
</span><span id="line-156"></span><span>      </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO Integer -&gt; IO Integer
forall a b c. IO a -&gt; IO b -&gt; IO c -&gt; IO c
</span><a href="../../base/src/Control.Exception.Base.html#bracket_"><span class="hs-identifier hs-var">bracket_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; TextEncoding -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetEncoding"><span class="hs-identifier hs-var">hSetEncoding</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782975"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="#local-6989586621680782962"><span class="hs-identifier hs-var">safeEncoding</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; Bool -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetBinaryMode"><span class="hs-identifier hs-var">hSetBinaryMode</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782975"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO Integer -&gt; IO Integer) -&gt; IO Integer -&gt; IO Integer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-157"></span><span>        </span><span id="local-6989586621680782960"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782960"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Char
</span><a href="../../base/src/GHC.IO.Handle.html#hLookAhead"><span class="hs-identifier hs-var">hLookAhead</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782975"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-158"></span><span>        </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782960"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\xfeff'</span></span><span>
</span><span id="line-159"></span><span>          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Char
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hGetChar"><span class="hs-identifier hs-var">hGetChar</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782975"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">IO Char -&gt; IO Integer -&gt; IO Integer
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Integer
</span><a href="../../base/src/GHC.IO.Handle.html#hTell"><span class="hs-identifier hs-var">hTell</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782975"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-160"></span><span>          </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; IO Integer
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782973"><span class="hs-identifier hs-var">offset</span></a></span><span>
</span><span id="line-161"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; IO Integer
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782973"><span class="hs-identifier hs-var">offset</span></a></span><span>
</span><span id="line-162"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-163"></span><span>    </span><span id="local-6989586621680782962"><span class="annot"><span class="annottext">safeEncoding :: TextEncoding
</span><a href="#local-6989586621680782962"><span class="hs-identifier hs-var hs-var">safeEncoding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CodingFailureMode -&gt; TextEncoding
</span><a href="../../base/src/GHC.IO.Encoding.UTF8.html#mkUTF8"><span class="hs-identifier hs-var">mkUTF8</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="../../base/src/GHC.IO.Encoding.Failure.html#IgnoreCodingFailure"><span class="hs-identifier hs-var">IgnoreCodingFailure</span></a></span><span>
</span><span id="line-164"></span><span>
</span><span id="line-165"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#newUTF8StringBuffer"><span class="hs-identifier hs-type">newUTF8StringBuffer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span>
</span><span id="line-166"></span><span id="newUTF8StringBuffer"><span class="annot"><span class="annottext">newUTF8StringBuffer :: ForeignPtr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO StringBuffer
</span><a href="GHC.Data.StringBuffer.html#newUTF8StringBuffer"><span class="hs-identifier hs-var hs-var">newUTF8StringBuffer</span></a></span></span><span> </span><span id="local-6989586621680782957"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782957"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span id="local-6989586621680782956"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782956"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span id="local-6989586621680782955"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782955"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-167"></span><span>  </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; [Word8] -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; [a] -&gt; IO ()
</span><a href="../../base/src/Foreign.Marshal.Array.html#pokeArray"><span class="hs-identifier hs-var">pokeArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782956"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782955"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0</span></span><span class="hs-special">]</span><span>
</span><span id="line-168"></span><span>  </span><span class="hs-comment">-- sentinels for UTF-8 decoding</span><span>
</span><span id="line-169"></span><span>  </span><span class="annot"><span class="annottext">StringBuffer -&gt; IO StringBuffer
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(StringBuffer -&gt; IO StringBuffer)
-&gt; StringBuffer -&gt; IO StringBuffer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; StringBuffer
</span><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-var">StringBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782957"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782955"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-170"></span><span>
</span><span id="line-171"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#appendStringBuffers"><span class="hs-identifier hs-type">appendStringBuffers</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span>
</span><span id="line-172"></span><span id="appendStringBuffers"><span class="annot"><span class="annottext">appendStringBuffers :: StringBuffer -&gt; StringBuffer -&gt; IO StringBuffer
</span><a href="GHC.Data.StringBuffer.html#appendStringBuffers"><span class="hs-identifier hs-var hs-var">appendStringBuffers</span></a></span></span><span> </span><span id="local-6989586621680782952"><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782952"><span class="hs-identifier hs-var">sb1</span></a></span></span><span> </span><span id="local-6989586621680782951"><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782951"><span class="hs-identifier hs-var">sb2</span></a></span></span><span>
</span><span id="line-173"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621680782950"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782950"><span class="hs-identifier hs-var">newBuf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr Word8)
forall a. Storable a =&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="../../base/src/Foreign.ForeignPtr.Imp.html#mallocForeignPtrArray"><span class="hs-identifier hs-var">mallocForeignPtrArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782949"><span class="hs-identifier hs-var">size</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span class="hs-special">)</span><span>
</span><span id="line-174"></span><span>         </span><span class="annot"><span class="annottext">ForeignPtr Word8
-&gt; (Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782950"><span class="hs-identifier hs-var">newBuf</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer)
-&gt; (Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680782948"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782948"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-175"></span><span>          </span><span class="annot"><span class="annottext">ForeignPtr Word8
-&gt; (Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StringBuffer -&gt; ForeignPtr Word8
</span><a href="GHC.Data.StringBuffer.html#buf"><span class="hs-identifier hs-var hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782952"><span class="hs-identifier hs-var">sb1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer)
-&gt; (Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680782947"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782947"><span class="hs-identifier hs-var">sb1Ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-176"></span><span>           </span><span class="annot"><span class="annottext">ForeignPtr Word8
-&gt; (Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StringBuffer -&gt; ForeignPtr Word8
</span><a href="GHC.Data.StringBuffer.html#buf"><span class="hs-identifier hs-var hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782951"><span class="hs-identifier hs-var">sb2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer)
-&gt; (Ptr Word8 -&gt; IO StringBuffer) -&gt; IO StringBuffer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680782946"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782946"><span class="hs-identifier hs-var">sb2Ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-177"></span><span>             </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/Foreign.Marshal.Array.html#copyArray"><span class="hs-identifier hs-var">copyArray</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782948"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782947"><span class="hs-identifier hs-var">sb1Ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; Ptr a
</span><a href="../../base/src/Foreign.Marshal.Array.html#advancePtr"><span class="hs-operator hs-var">`advancePtr`</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#cur"><span class="hs-identifier hs-var hs-var">cur</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782952"><span class="hs-identifier hs-var">sb1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782943"><span class="hs-identifier hs-var">sb1_len</span></a></span><span>
</span><span id="line-178"></span><span>                </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/Foreign.Marshal.Array.html#copyArray"><span class="hs-identifier hs-var">copyArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782948"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; Ptr a
</span><a href="../../base/src/Foreign.Marshal.Array.html#advancePtr"><span class="hs-operator hs-var">`advancePtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782943"><span class="hs-identifier hs-var">sb1_len</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782946"><span class="hs-identifier hs-var">sb2Ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; Ptr a
</span><a href="../../base/src/Foreign.Marshal.Array.html#advancePtr"><span class="hs-operator hs-var">`advancePtr`</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#cur"><span class="hs-identifier hs-var hs-var">cur</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782951"><span class="hs-identifier hs-var">sb2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782942"><span class="hs-identifier hs-var">sb2_len</span></a></span><span>
</span><span id="line-179"></span><span>                </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; [Word8] -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; [a] -&gt; IO ()
</span><a href="../../base/src/Foreign.Marshal.Array.html#pokeArray"><span class="hs-identifier hs-var">pokeArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782948"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; Ptr a
</span><a href="../../base/src/Foreign.Marshal.Array.html#advancePtr"><span class="hs-operator hs-var">`advancePtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782949"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0</span></span><span class="hs-special">]</span><span>
</span><span id="line-180"></span><span>                </span><span class="annot"><span class="annottext">StringBuffer -&gt; IO StringBuffer
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; StringBuffer
</span><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-var">StringBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782950"><span class="hs-identifier hs-var">newBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782949"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-181"></span><span>    </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680782943"><span class="annot"><span class="annottext">sb1_len :: Int
</span><a href="#local-6989586621680782943"><span class="hs-identifier hs-var hs-var">sb1_len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="#local-6989586621680782941"><span class="hs-identifier hs-var">calcLen</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782952"><span class="hs-identifier hs-var">sb1</span></a></span><span>
</span><span id="line-182"></span><span>          </span><span id="local-6989586621680782942"><span class="annot"><span class="annottext">sb2_len :: Int
</span><a href="#local-6989586621680782942"><span class="hs-identifier hs-var hs-var">sb2_len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="#local-6989586621680782941"><span class="hs-identifier hs-var">calcLen</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782951"><span class="hs-identifier hs-var">sb2</span></a></span><span>
</span><span id="line-183"></span><span>          </span><span id="local-6989586621680782941"><span class="annot"><span class="annottext">calcLen :: StringBuffer -&gt; Int
</span><a href="#local-6989586621680782941"><span class="hs-identifier hs-var hs-var">calcLen</span></a></span></span><span> </span><span id="local-6989586621680782939"><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782939"><span class="hs-identifier hs-var">sb</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#len"><span class="hs-identifier hs-var hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782939"><span class="hs-identifier hs-var">sb</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#cur"><span class="hs-identifier hs-var hs-var">cur</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782939"><span class="hs-identifier hs-var">sb</span></a></span><span>
</span><span id="line-184"></span><span>          </span><span id="local-6989586621680782949"><span class="annot"><span class="annottext">size :: Int
</span><a href="#local-6989586621680782949"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782943"><span class="hs-identifier hs-var">sb1_len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782942"><span class="hs-identifier hs-var">sb2_len</span></a></span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span class="hs-comment">-- | Encode a 'String' into a 'StringBuffer' as UTF-8.  The resulting buffer</span><span>
</span><span id="line-187"></span><span class="hs-comment">-- is automatically managed by the garbage collector.</span><span>
</span><span id="line-188"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#stringToStringBuffer"><span class="hs-identifier hs-type">stringToStringBuffer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span>
</span><span id="line-189"></span><span id="stringToStringBuffer"><span class="annot"><span class="annottext">stringToStringBuffer :: String -&gt; StringBuffer
</span><a href="GHC.Data.StringBuffer.html#stringToStringBuffer"><span class="hs-identifier hs-var hs-var">stringToStringBuffer</span></a></span></span><span> </span><span id="local-6989586621680782937"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782937"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-190"></span><span> </span><span class="annot"><span class="annottext">IO StringBuffer -&gt; StringBuffer
forall a. IO a -&gt; a
</span><a href="../../base/src/GHC.IO.Unsafe.html#unsafePerformIO"><span class="hs-identifier hs-var">unsafePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO StringBuffer -&gt; StringBuffer)
-&gt; IO StringBuffer -&gt; StringBuffer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-191"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680782936"><span class="annot"><span class="annottext">size :: Int
</span><a href="#local-6989586621680782936"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Int
</span><a href="GHC.Utils.Encoding.html#utf8EncodedLength"><span class="hs-identifier hs-var">utf8EncodedLength</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782937"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-192"></span><span>  </span><span id="local-6989586621680782934"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782934"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr Word8)
forall a. Storable a =&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="../../base/src/Foreign.ForeignPtr.Imp.html#mallocForeignPtrArray"><span class="hs-identifier hs-var">mallocForeignPtrArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782936"><span class="hs-identifier hs-var">size</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span class="hs-special">)</span><span>
</span><span id="line-193"></span><span>  </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782934"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680782933"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782933"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-194"></span><span>    </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; String -&gt; IO ()
</span><a href="GHC.Utils.Encoding.html#utf8EncodeString"><span class="hs-identifier hs-var">utf8EncodeString</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782933"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782937"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-195"></span><span>    </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; [Word8] -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; [a] -&gt; IO ()
</span><a href="../../base/src/Foreign.Marshal.Array.html#pokeArray"><span class="hs-identifier hs-var">pokeArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782933"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782936"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0</span></span><span class="hs-special">]</span><span>
</span><span id="line-196"></span><span>    </span><span class="hs-comment">-- sentinels for UTF-8 decoding</span><span>
</span><span id="line-197"></span><span>  </span><span class="annot"><span class="annottext">StringBuffer -&gt; IO StringBuffer
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; StringBuffer
</span><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-var">StringBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782934"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782936"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-198"></span><span>
</span><span id="line-199"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-200"></span><span class="hs-comment">-- Grab a character</span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span class="hs-comment">-- | Return the first UTF-8 character of a nonempty 'StringBuffer' and as well</span><span>
</span><span id="line-203"></span><span class="hs-comment">-- the remaining portion (analogous to 'Data.List.uncons').  __Warning:__ The</span><span>
</span><span id="line-204"></span><span class="hs-comment">-- behavior is undefined if the 'StringBuffer' is empty.  The result shares</span><span>
</span><span id="line-205"></span><span class="hs-comment">-- the same buffer as the original.  Similar to 'utf8DecodeChar', if the</span><span>
</span><span id="line-206"></span><span class="hs-comment">-- character cannot be decoded as UTF-8, @\'\\0\'@ is returned.</span><span>
</span><span id="line-207"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#nextChar"><span class="hs-pragma hs-type">nextChar</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-208"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#nextChar"><span class="hs-identifier hs-type">nextChar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-209"></span><span id="nextChar"><span class="annot"><span class="annottext">nextChar :: StringBuffer -&gt; (Char, StringBuffer)
</span><a href="GHC.Data.StringBuffer.html#nextChar"><span class="hs-identifier hs-var hs-var">nextChar</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span id="local-6989586621680782931"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782931"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span id="local-6989586621680782930"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782930"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">I#</span></span><span> </span><span id="local-6989586621680782929"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782929"><span class="hs-identifier hs-var">cur#</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-210"></span><span>  </span><span class="hs-comment">-- Getting our fingers dirty a little here, but this is performance-critical</span><span>
</span><span id="line-211"></span><span>  </span><span class="annot"><span class="annottext">IO (Char, StringBuffer) -&gt; (Char, StringBuffer)
forall a. IO a -&gt; a
</span><a href="GHC.Utils.IO.Unsafe.html#inlinePerformIO"><span class="hs-identifier hs-var">inlinePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (Char, StringBuffer) -&gt; (Char, StringBuffer))
-&gt; IO (Char, StringBuffer) -&gt; (Char, StringBuffer)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-212"></span><span>    </span><span class="annot"><span class="annottext">ForeignPtr Word8
-&gt; (Ptr Word8 -&gt; IO (Char, StringBuffer))
-&gt; IO (Char, StringBuffer)
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782931"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO (Char, StringBuffer)) -&gt; IO (Char, StringBuffer))
-&gt; (Ptr Word8 -&gt; IO (Char, StringBuffer))
-&gt; IO (Char, StringBuffer)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span id="local-6989586621680782926"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621680782926"><span class="hs-identifier hs-var">a#</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-213"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; Int# -&gt; (# Char#, Int# #)
</span><a href="GHC.Utils.Encoding.html#utf8DecodeCharAddr%23"><span class="hs-identifier hs-var">utf8DecodeCharAddr#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621680782926"><span class="hs-identifier hs-var">a#</span></a></span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; Int# -&gt; Addr#
</span><span class="hs-operator hs-var">`plusAddr#`</span></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782929"><span class="hs-identifier hs-var">cur#</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">0#</span></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-214"></span><span>          </span><span class="hs-special">(#</span><span> </span><span id="local-6989586621680782924"><span class="annot"><span class="annottext">Char#
</span><a href="#local-6989586621680782924"><span class="hs-identifier hs-var">c#</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680782923"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782923"><span class="hs-identifier hs-var">nBytes#</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-215"></span><span>             </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680782922"><span class="annot"><span class="annottext">cur' :: Int
</span><a href="#local-6989586621680782922"><span class="hs-identifier hs-var hs-var">cur'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int
</span><span class="hs-identifier hs-var">I#</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782929"><span class="hs-identifier hs-var">cur#</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><span class="hs-operator hs-var">+#</span></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782923"><span class="hs-identifier hs-var">nBytes#</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">in</span><span>
</span><span id="line-216"></span><span>             </span><span class="annot"><span class="annottext">(Char, StringBuffer) -&gt; IO (Char, StringBuffer)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char# -&gt; Char
</span><span class="hs-identifier hs-var">C#</span></span><span> </span><span class="annot"><span class="annottext">Char#
</span><a href="#local-6989586621680782924"><span class="hs-identifier hs-var">c#</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; StringBuffer
</span><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-var">StringBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782931"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782930"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782922"><span class="hs-identifier hs-var">cur'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-217"></span><span>
</span><span id="line-218"></span><span>
</span><span id="line-219"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#bidirectionalFormatChars"><span class="hs-identifier hs-type">bidirectionalFormatChars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-220"></span><span id="bidirectionalFormatChars"><span class="annot"><span class="annottext">bidirectionalFormatChars :: [(Char, String)]
</span><a href="GHC.Data.StringBuffer.html#bidirectionalFormatChars"><span class="hs-identifier hs-var hs-var">bidirectionalFormatChars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-221"></span><span>  </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\x202a'</span></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;U+202A LEFT-TO-RIGHT EMBEDDING (LRE)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-222"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\x202b'</span></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;U+202B RIGHT-TO-LEFT EMBEDDING (RLE)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-223"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\x202c'</span></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;U+202C POP DIRECTIONAL FORMATTING (PDF)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-224"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\x202d'</span></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;U+202D LEFT-TO-RIGHT OVERRIDE (LRO)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-225"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\x202e'</span></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;U+202E RIGHT-TO-LEFT OVERRIDE (RLO)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-226"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\x2066'</span></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;U+2066 LEFT-TO-RIGHT ISOLATE (LRI)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-227"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\x2067'</span></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;U+2067 RIGHT-TO-LEFT ISOLATE (RLI)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-228"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\x2068'</span></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;U+2068 FIRST STRONG ISOLATE (FSI)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-229"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\x2069'</span></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;U+2069 POP DIRECTIONAL ISOLATE (PDI)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-230"></span><span>  </span><span class="hs-special">]</span><span>
</span><span id="line-231"></span><span>
</span><span id="line-232"></span><span class="hs-comment">{-| Returns true if the buffer contains Unicode bi-directional formatting
characters.

https://www.unicode.org/reports/tr9/#Bidirectional_Character_Types

Bidirectional format characters are one of
'\x202a' : &quot;U+202A LEFT-TO-RIGHT EMBEDDING (LRE)&quot;
'\x202b' : &quot;U+202B RIGHT-TO-LEFT EMBEDDING (RLE)&quot;
'\x202c' : &quot;U+202C POP DIRECTIONAL FORMATTING (PDF)&quot;
'\x202d' : &quot;U+202D LEFT-TO-RIGHT OVERRIDE (LRO)&quot;
'\x202e' : &quot;U+202E RIGHT-TO-LEFT OVERRIDE (RLO)&quot;
'\x2066' : &quot;U+2066 LEFT-TO-RIGHT ISOLATE (LRI)&quot;
'\x2067' : &quot;U+2067 RIGHT-TO-LEFT ISOLATE (RLI)&quot;
'\x2068' : &quot;U+2068 FIRST STRONG ISOLATE (FSI)&quot;
'\x2069' : &quot;U+2069 POP DIRECTIONAL ISOLATE (PDI)&quot;

This list is encoded in 'bidirectionalFormatChars'

-}</span><span>
</span><span id="line-251"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#containsBidirectionalFormatChar"><span class="hs-pragma hs-type">containsBidirectionalFormatChar</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-252"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#containsBidirectionalFormatChar"><span class="hs-identifier hs-type">containsBidirectionalFormatChar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-253"></span><span id="containsBidirectionalFormatChar"><span class="annot"><span class="annottext">containsBidirectionalFormatChar :: StringBuffer -&gt; Bool
</span><a href="GHC.Data.StringBuffer.html#containsBidirectionalFormatChar"><span class="hs-identifier hs-var hs-var">containsBidirectionalFormatChar</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span id="local-6989586621680782921"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782921"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">I#</span></span><span> </span><span id="local-6989586621680782920"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782920"><span class="hs-identifier hs-var">len#</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">I#</span></span><span> </span><span id="local-6989586621680782919"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782919"><span class="hs-identifier hs-var">cur#</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-254"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO Bool -&gt; Bool
forall a. IO a -&gt; a
</span><a href="GHC.Utils.IO.Unsafe.html#inlinePerformIO"><span class="hs-identifier hs-var">inlinePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO Bool -&gt; Bool) -&gt; IO Bool -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO Bool) -&gt; IO Bool
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782921"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO Bool) -&gt; IO Bool)
-&gt; (Ptr Word8 -&gt; IO Bool) -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span id="local-6989586621680782918"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621680782918"><span class="hs-identifier hs-var">a#</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-255"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span class="annot"><a href="#local-6989586621680782917"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int#</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-256"></span><span>      </span><span id="local-6989586621680782917"><span class="annot"><span class="annottext">go :: Int# -&gt; Bool
</span><a href="#local-6989586621680782917"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680782916"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782916"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Bool
</span><span class="hs-identifier hs-var">isTrue#</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782916"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><span class="hs-operator hs-var">&gt;=#</span></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782920"><span class="hs-identifier hs-var">len#</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-257"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; Int# -&gt; (# Char#, Int# #)
</span><a href="GHC.Utils.Encoding.html#utf8DecodeCharAddr%23"><span class="hs-identifier hs-var">utf8DecodeCharAddr#</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621680782918"><span class="hs-identifier hs-var">a#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782916"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-258"></span><span>                </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Char#
</span><span class="hs-char">'\x202a'#</span></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-259"></span><span>                </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Char#
</span><span class="hs-char">'\x202b'#</span></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-260"></span><span>                </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Char#
</span><span class="hs-char">'\x202c'#</span></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-261"></span><span>                </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Char#
</span><span class="hs-char">'\x202d'#</span></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-262"></span><span>                </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Char#
</span><span class="hs-char">'\x202e'#</span></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-263"></span><span>                </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Char#
</span><span class="hs-char">'\x2066'#</span></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-264"></span><span>                </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Char#
</span><span class="hs-char">'\x2067'#</span></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-265"></span><span>                </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Char#
</span><span class="hs-char">'\x2068'#</span></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-266"></span><span>                </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Char#
</span><span class="hs-char">'\x2069'#</span></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-267"></span><span>                </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Char#
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680782914"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782914"><span class="hs-identifier hs-var">bytes</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Bool
</span><a href="#local-6989586621680782917"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782916"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><span class="hs-operator hs-var">+#</span></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782914"><span class="hs-identifier hs-var">bytes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-268"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; IO Bool) -&gt; Bool -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Bool
</span><a href="#local-6989586621680782917"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621680782919"><span class="hs-identifier hs-var">cur#</span></a></span><span>
</span><span id="line-269"></span><span>
</span><span id="line-270"></span><span class="hs-comment">-- | Return the first UTF-8 character of a nonempty 'StringBuffer' (analogous</span><span>
</span><span id="line-271"></span><span class="hs-comment">-- to 'Data.List.head').  __Warning:__ The behavior is undefined if the</span><span>
</span><span id="line-272"></span><span class="hs-comment">-- 'StringBuffer' is empty.  Similar to 'utf8DecodeChar', if the character</span><span>
</span><span id="line-273"></span><span class="hs-comment">-- cannot be decoded as UTF-8, @\'\\0\'@ is returned.</span><span>
</span><span id="line-274"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#currentChar"><span class="hs-identifier hs-type">currentChar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span>
</span><span id="line-275"></span><span id="currentChar"><span class="annot"><span class="annottext">currentChar :: StringBuffer -&gt; Char
</span><a href="GHC.Data.StringBuffer.html#currentChar"><span class="hs-identifier hs-var hs-var">currentChar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char, StringBuffer) -&gt; Char
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">((Char, StringBuffer) -&gt; Char)
-&gt; (StringBuffer -&gt; (Char, StringBuffer)) -&gt; StringBuffer -&gt; Char
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer -&gt; (Char, StringBuffer)
</span><a href="GHC.Data.StringBuffer.html#nextChar"><span class="hs-identifier hs-var">nextChar</span></a></span><span>
</span><span id="line-276"></span><span>
</span><span id="line-277"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#prevChar"><span class="hs-identifier hs-type">prevChar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span>
</span><span id="line-278"></span><span id="prevChar"><span class="annot"><span class="annottext">prevChar :: StringBuffer -&gt; Char -&gt; Char
</span><a href="GHC.Data.StringBuffer.html#prevChar"><span class="hs-identifier hs-var hs-var">prevChar</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span>   </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span>   </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>   </span><span id="local-6989586621680782912"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782912"><span class="hs-identifier hs-var">deflt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782912"><span class="hs-identifier hs-var">deflt</span></a></span><span>
</span><span id="line-279"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#prevChar"><span class="hs-identifier hs-var">prevChar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span id="local-6989586621680782911"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782911"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span>   </span><span id="local-6989586621680782910"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782910"><span class="hs-identifier hs-var">cur</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">=</span><span>
</span><span id="line-280"></span><span>  </span><span class="annot"><span class="annottext">IO Char -&gt; Char
forall a. IO a -&gt; a
</span><a href="GHC.Utils.IO.Unsafe.html#inlinePerformIO"><span class="hs-identifier hs-var">inlinePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO Char -&gt; Char) -&gt; IO Char -&gt; Char
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-281"></span><span>    </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO Char) -&gt; IO Char
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782911"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO Char) -&gt; IO Char)
-&gt; (Ptr Word8 -&gt; IO Char) -&gt; IO Char
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680782909"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782909"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-282"></span><span>      </span><span id="local-6989586621680782908"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782908"><span class="hs-identifier hs-var">p'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="GHC.Utils.Encoding.html#utf8PrevChar"><span class="hs-identifier hs-var">utf8PrevChar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782909"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782910"><span class="hs-identifier hs-var">cur</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-283"></span><span>      </span><span class="annot"><span class="annottext">Char -&gt; IO Char
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Char, Int) -&gt; Char
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8 -&gt; (Char, Int)
</span><a href="GHC.Utils.Encoding.html#utf8DecodeChar"><span class="hs-identifier hs-var">utf8DecodeChar</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782908"><span class="hs-identifier hs-var">p'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-284"></span><span>
</span><span id="line-285"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-286"></span><span class="hs-comment">-- Moving</span><span>
</span><span id="line-287"></span><span>
</span><span id="line-288"></span><span class="hs-comment">-- | Return a 'StringBuffer' with the first UTF-8 character removed (analogous</span><span>
</span><span id="line-289"></span><span class="hs-comment">-- to 'Data.List.tail').  __Warning:__ The behavior is undefined if the</span><span>
</span><span id="line-290"></span><span class="hs-comment">-- 'StringBuffer' is empty.  The result shares the same buffer as the</span><span>
</span><span id="line-291"></span><span class="hs-comment">-- original.</span><span>
</span><span id="line-292"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#stepOn"><span class="hs-identifier hs-type">stepOn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span>
</span><span id="line-293"></span><span id="stepOn"><span class="annot"><span class="annottext">stepOn :: StringBuffer -&gt; StringBuffer
</span><a href="GHC.Data.StringBuffer.html#stepOn"><span class="hs-identifier hs-var hs-var">stepOn</span></a></span></span><span> </span><span id="local-6989586621680782905"><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782905"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char, StringBuffer) -&gt; StringBuffer
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StringBuffer -&gt; (Char, StringBuffer)
</span><a href="GHC.Data.StringBuffer.html#nextChar"><span class="hs-identifier hs-var">nextChar</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782905"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-294"></span><span>
</span><span id="line-295"></span><span class="hs-comment">-- | Return a 'StringBuffer' with the first @n@ bytes removed.  __Warning:__</span><span>
</span><span id="line-296"></span><span class="hs-comment">-- If there aren't enough characters, the returned 'StringBuffer' will be</span><span>
</span><span id="line-297"></span><span class="hs-comment">-- invalid and any use of it may lead to undefined behavior.  The result</span><span>
</span><span id="line-298"></span><span class="hs-comment">-- shares the same buffer as the original.</span><span>
</span><span id="line-299"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#offsetBytes"><span class="hs-identifier hs-type">offsetBytes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>                      </span><span class="hs-comment">-- ^ @n@, the number of bytes</span><span>
</span><span id="line-300"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span>
</span><span id="line-301"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span>
</span><span id="line-302"></span><span id="offsetBytes"><span class="annot"><span class="annottext">offsetBytes :: Int -&gt; StringBuffer -&gt; StringBuffer
</span><a href="GHC.Data.StringBuffer.html#offsetBytes"><span class="hs-identifier hs-var hs-var">offsetBytes</span></a></span></span><span> </span><span id="local-6989586621680782904"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782904"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span id="local-6989586621680782903"><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782903"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782903"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cur :: Int
</span><a href="GHC.Data.StringBuffer.html#cur"><span class="hs-identifier hs-var">cur</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#cur"><span class="hs-identifier hs-var hs-var">cur</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782903"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782904"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-303"></span><span>
</span><span id="line-304"></span><span class="hs-comment">-- | Compute the difference in offset between two 'StringBuffer's that share</span><span>
</span><span id="line-305"></span><span class="hs-comment">-- the same buffer.  __Warning:__ The behavior is undefined if the</span><span>
</span><span id="line-306"></span><span class="hs-comment">-- 'StringBuffer's use separate buffers.</span><span>
</span><span id="line-307"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#byteDiff"><span class="hs-identifier hs-type">byteDiff</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-308"></span><span id="byteDiff"><span class="annot"><span class="annottext">byteDiff :: StringBuffer -&gt; StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#byteDiff"><span class="hs-identifier hs-var hs-var">byteDiff</span></a></span></span><span> </span><span id="local-6989586621680782902"><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782902"><span class="hs-identifier hs-var">s1</span></a></span></span><span> </span><span id="local-6989586621680782901"><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782901"><span class="hs-identifier hs-var">s2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#cur"><span class="hs-identifier hs-var hs-var">cur</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782901"><span class="hs-identifier hs-var">s2</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer -&gt; Int
</span><a href="GHC.Data.StringBuffer.html#cur"><span class="hs-identifier hs-var hs-var">cur</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782902"><span class="hs-identifier hs-var">s1</span></a></span><span>
</span><span id="line-309"></span><span>
</span><span id="line-310"></span><span class="hs-comment">-- | Check whether a 'StringBuffer' is empty (analogous to 'Data.List.null').</span><span>
</span><span id="line-311"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#atEnd"><span class="hs-identifier hs-type">atEnd</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-312"></span><span id="atEnd"><span class="annot"><span class="annottext">atEnd :: StringBuffer -&gt; Bool
</span><a href="GHC.Data.StringBuffer.html#atEnd"><span class="hs-identifier hs-var hs-var">atEnd</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680782900"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782900"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span id="local-6989586621680782899"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782899"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782900"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782899"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-313"></span><span>
</span><span id="line-314"></span><span class="hs-comment">-- | Computes a 'StringBuffer' which points to the first character of the</span><span>
</span><span id="line-315"></span><span class="hs-comment">-- wanted line. Lines begin at 1.</span><span>
</span><span id="line-316"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#atLine"><span class="hs-identifier hs-type">atLine</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span>
</span><span id="line-317"></span><span id="atLine"><span class="annot"><span class="annottext">atLine :: Int -&gt; StringBuffer -&gt; Maybe StringBuffer
</span><a href="GHC.Data.StringBuffer.html#atLine"><span class="hs-identifier hs-var hs-var">atLine</span></a></span></span><span> </span><span id="local-6989586621680782898"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782898"><span class="hs-identifier hs-var">line</span></a></span></span><span> </span><span id="local-6989586621680782897"><span class="annot"><span class="annottext">sb :: StringBuffer
</span><a href="#local-6989586621680782897"><span class="hs-identifier hs-var">sb</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span id="local-6989586621680782896"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782896"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span id="local-6989586621680782895"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782895"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-318"></span><span>  </span><span class="annot"><span class="annottext">IO (Maybe StringBuffer) -&gt; Maybe StringBuffer
forall a. IO a -&gt; a
</span><a href="GHC.Utils.IO.Unsafe.html#inlinePerformIO"><span class="hs-identifier hs-var">inlinePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (Maybe StringBuffer) -&gt; Maybe StringBuffer)
-&gt; IO (Maybe StringBuffer) -&gt; Maybe StringBuffer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-319"></span><span>    </span><span class="annot"><span class="annottext">ForeignPtr Word8
-&gt; (Ptr Word8 -&gt; IO (Maybe StringBuffer))
-&gt; IO (Maybe StringBuffer)
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782896"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO (Maybe StringBuffer)) -&gt; IO (Maybe StringBuffer))
-&gt; (Ptr Word8 -&gt; IO (Maybe StringBuffer))
-&gt; IO (Maybe StringBuffer)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680782894"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782894"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-320"></span><span>      </span><span id="local-6989586621680782893"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782893"><span class="hs-identifier hs-var">p'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="GHC.Data.StringBuffer.html#skipToLine"><span class="hs-identifier hs-var">skipToLine</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782898"><span class="hs-identifier hs-var">line</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782895"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782894"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-321"></span><span>      </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782893"><span class="hs-identifier hs-var">p'</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall a. Ptr a
</span><a href="../../base/src/GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span>
</span><span id="line-322"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe StringBuffer -&gt; IO (Maybe StringBuffer)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe StringBuffer
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-323"></span><span>        </span><span class="hs-keyword">else</span><span>
</span><span id="line-324"></span><span>          </span><span class="hs-keyword">let</span><span>
</span><span id="line-325"></span><span>            </span><span id="local-6989586621680782890"><span class="annot"><span class="annottext">delta :: Int
</span><a href="#local-6989586621680782890"><span class="hs-identifier hs-var hs-var">delta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782893"><span class="hs-identifier hs-var">p'</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int
forall a b. Ptr a -&gt; Ptr b -&gt; Int
</span><a href="../../base/src/GHC.Ptr.html#minusPtr"><span class="hs-operator hs-var">`minusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782894"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-326"></span><span>          </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Maybe StringBuffer -&gt; IO (Maybe StringBuffer)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe StringBuffer -&gt; IO (Maybe StringBuffer))
-&gt; Maybe StringBuffer -&gt; IO (Maybe StringBuffer)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">StringBuffer -&gt; Maybe StringBuffer
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StringBuffer
</span><a href="#local-6989586621680782897"><span class="hs-identifier hs-var">sb</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cur :: Int
</span><a href="GHC.Data.StringBuffer.html#cur"><span class="hs-identifier hs-var">cur</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782890"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-327"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">len :: Int
</span><a href="GHC.Data.StringBuffer.html#len"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782895"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782890"><span class="hs-identifier hs-var">delta</span></a></span><span>
</span><span id="line-328"></span><span>                               </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span>
</span><span id="line-330"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#skipToLine"><span class="hs-identifier hs-type">skipToLine</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-331"></span><span id="skipToLine"><span class="annot"><span class="annottext">skipToLine :: Int -&gt; Int -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="GHC.Data.StringBuffer.html#skipToLine"><span class="hs-identifier hs-var hs-var">skipToLine</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680782888"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782888"><span class="hs-identifier hs-var">line</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680782887"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782887"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680782886"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782886"><span class="hs-identifier hs-var">op0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="#local-6989586621680782885"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782886"><span class="hs-identifier hs-var">op0</span></a></span><span>
</span><span id="line-332"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-333"></span><span>    </span><span class="hs-glyph">!</span><span id="local-6989586621680782884"><span class="annot"><span class="annottext">opend :: Ptr b
</span><a href="#local-6989586621680782884"><span class="hs-identifier hs-var hs-var">opend</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782886"><span class="hs-identifier hs-var">op0</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr b
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782887"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-334"></span><span>
</span><span id="line-335"></span><span>    </span><span id="local-6989586621680782885"><span class="annot"><span class="annottext">go :: Int -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="#local-6989586621680782885"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680782862"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782862"><span class="hs-identifier hs-var">i_line</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680782861"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782861"><span class="hs-identifier hs-var">op</span></a></span></span><span>
</span><span id="line-336"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782861"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall a. Ptr a
</span><a href="#local-6989586621680782884"><span class="hs-identifier hs-var">opend</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO (Ptr Word8)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall a. Ptr a
</span><a href="../../base/src/GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span>
</span><span id="line-337"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782862"><span class="hs-identifier hs-var">i_line</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782888"><span class="hs-identifier hs-var">line</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO (Ptr Word8)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782861"><span class="hs-identifier hs-var">op</span></a></span><span>
</span><span id="line-338"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-339"></span><span>          </span><span id="local-6989586621680782860"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680782860"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Word8
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782861"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-340"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680782860"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-341"></span><span>            </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">10</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="#local-6989586621680782885"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782862"><span class="hs-identifier hs-var">i_line</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-identifier hs-var">plusPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782861"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-342"></span><span>            </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">13</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-343"></span><span>              </span><span class="hs-comment">-- this is safe because a 'StringBuffer' is</span><span>
</span><span id="line-344"></span><span>              </span><span class="hs-comment">-- guaranteed to have 3 bytes sentinel values.</span><span>
</span><span id="line-345"></span><span>              </span><span id="local-6989586621680782858"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680782858"><span class="hs-identifier hs-var">w'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Word8
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-identifier hs-var">plusPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782861"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-346"></span><span>              </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680782858"><span class="hs-identifier hs-var">w'</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-347"></span><span>                </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">10</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="#local-6989586621680782885"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782862"><span class="hs-identifier hs-var">i_line</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-identifier hs-var">plusPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782861"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span>
</span><span id="line-348"></span><span>                </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="#local-6989586621680782885"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782862"><span class="hs-identifier hs-var">i_line</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-identifier hs-var">plusPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782861"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-349"></span><span>            </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="#local-6989586621680782885"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782862"><span class="hs-identifier hs-var">i_line</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-identifier hs-var">plusPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782861"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-350"></span><span>
</span><span id="line-351"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-352"></span><span class="hs-comment">-- Conversion</span><span>
</span><span id="line-353"></span><span>
</span><span id="line-354"></span><span class="hs-comment">-- | Decode the first @n@ bytes of a 'StringBuffer' as UTF-8 into a 'String'.</span><span>
</span><span id="line-355"></span><span class="hs-comment">-- Similar to 'utf8DecodeChar', if the character cannot be decoded as UTF-8,</span><span>
</span><span id="line-356"></span><span class="hs-comment">-- they will be replaced with @\'\\0\'@.</span><span>
</span><span id="line-357"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#lexemeToString"><span class="hs-identifier hs-type">lexemeToString</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span>
</span><span id="line-358"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>                   </span><span class="hs-comment">-- ^ @n@, the number of bytes</span><span>
</span><span id="line-359"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-360"></span><span id="lexemeToString"><span class="annot"><span class="annottext">lexemeToString :: StringBuffer -&gt; Int -&gt; String
</span><a href="GHC.Data.StringBuffer.html#lexemeToString"><span class="hs-identifier hs-var hs-var">lexemeToString</span></a></span></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span>
</span><span id="line-361"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#lexemeToString"><span class="hs-identifier hs-var">lexemeToString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span id="local-6989586621680782857"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782857"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680782856"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782856"><span class="hs-identifier hs-var">cur</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680782855"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782855"><span class="hs-identifier hs-var">bytes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-362"></span><span>  </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; String
</span><a href="GHC.Utils.Encoding.html#utf8DecodeStringLazy"><span class="hs-identifier hs-var">utf8DecodeStringLazy</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782857"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782856"><span class="hs-identifier hs-var">cur</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782855"><span class="hs-identifier hs-var">bytes</span></a></span><span>
</span><span id="line-363"></span><span>
</span><span id="line-364"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#lexemeToFastString"><span class="hs-identifier hs-type">lexemeToFastString</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span>
</span><span id="line-365"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>               </span><span class="hs-comment">-- ^ @n@, the number of bytes</span><span>
</span><span id="line-366"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span><span>
</span><span id="line-367"></span><span id="lexemeToFastString"><span class="annot"><span class="annottext">lexemeToFastString :: StringBuffer -&gt; Int -&gt; FastString
</span><a href="GHC.Data.StringBuffer.html#lexemeToFastString"><span class="hs-identifier hs-var hs-var">lexemeToFastString</span></a></span></span><span> </span><span class="annot"><span class="annottext">StringBuffer
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="GHC.Data.FastString.html#nilFS"><span class="hs-identifier hs-var">nilFS</span></a></span><span>
</span><span id="line-368"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#lexemeToFastString"><span class="hs-identifier hs-var">lexemeToFastString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span id="local-6989586621680782852"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782852"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680782851"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782851"><span class="hs-identifier hs-var">cur</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680782850"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782850"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-369"></span><span>   </span><span class="annot"><span class="annottext">IO FastString -&gt; FastString
forall a. IO a -&gt; a
</span><a href="GHC.Utils.IO.Unsafe.html#inlinePerformIO"><span class="hs-identifier hs-var">inlinePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO FastString -&gt; FastString) -&gt; IO FastString -&gt; FastString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-370"></span><span>     </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO FastString) -&gt; IO FastString
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782852"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO FastString) -&gt; IO FastString)
-&gt; (Ptr Word8 -&gt; IO FastString) -&gt; IO FastString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680782849"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782849"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-371"></span><span>       </span><span class="annot"><span class="annottext">FastString -&gt; IO FastString
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(FastString -&gt; IO FastString) -&gt; FastString -&gt; IO FastString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; FastString
</span><a href="GHC.Data.FastString.html#mkFastStringBytes"><span class="hs-identifier hs-var">mkFastStringBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782849"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782851"><span class="hs-identifier hs-var">cur</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782850"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-372"></span><span>
</span><span id="line-373"></span><span class="hs-comment">-- | Return the previous @n@ characters (or fewer if we are less than @n@</span><span>
</span><span id="line-374"></span><span class="hs-comment">-- characters into the buffer.</span><span>
</span><span id="line-375"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#decodePrevNChars"><span class="hs-identifier hs-type">decodePrevNChars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-376"></span><span id="decodePrevNChars"><span class="annot"><span class="annottext">decodePrevNChars :: Int -&gt; StringBuffer -&gt; String
</span><a href="GHC.Data.StringBuffer.html#decodePrevNChars"><span class="hs-identifier hs-var hs-var">decodePrevNChars</span></a></span></span><span> </span><span id="local-6989586621680782847"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782847"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span id="local-6989586621680782846"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782846"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680782845"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782845"><span class="hs-identifier hs-var">cur</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-377"></span><span>    </span><span class="annot"><span class="annottext">IO String -&gt; String
forall a. IO a -&gt; a
</span><a href="GHC.Utils.IO.Unsafe.html#inlinePerformIO"><span class="hs-identifier hs-var">inlinePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO String -&gt; String) -&gt; IO String -&gt; String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO String) -&gt; IO String
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782846"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO String) -&gt; IO String)
-&gt; (Ptr Word8 -&gt; IO String) -&gt; IO String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680782844"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782844"><span class="hs-identifier hs-var">p0</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-378"></span><span>      </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; String -&gt; Ptr Word8 -&gt; IO String
</span><a href="#local-6989586621680782843"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782844"><span class="hs-identifier hs-var">p0</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782847"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782844"><span class="hs-identifier hs-var">p0</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782845"><span class="hs-identifier hs-var">cur</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-379"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-380"></span><span>    </span><span class="annot"><a href="#local-6989586621680782843"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-381"></span><span>    </span><span id="local-6989586621680782843"><span class="annot"><span class="annottext">go :: Ptr Word8 -&gt; Int -&gt; String -&gt; Ptr Word8 -&gt; IO String
</span><a href="#local-6989586621680782843"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680782842"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782842"><span class="hs-identifier hs-var">buf0</span></a></span></span><span> </span><span id="local-6989586621680782841"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782841"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621680782840"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782840"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span id="local-6989586621680782839"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782839"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782841"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782842"><span class="hs-identifier hs-var">buf0</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782839"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO String
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782840"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-382"></span><span>    </span><span class="annot"><a href="#local-6989586621680782843"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680782837"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782837"><span class="hs-identifier hs-var">buf0</span></a></span></span><span> </span><span id="local-6989586621680782836"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782836"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621680782835"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782835"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span id="local-6989586621680782834"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782834"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-383"></span><span>        </span><span id="local-6989586621680782833"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782833"><span class="hs-identifier hs-var">p'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="GHC.Utils.Encoding.html#utf8PrevChar"><span class="hs-identifier hs-var">utf8PrevChar</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782834"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-384"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680782832"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782832"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; (Char, Int)
</span><a href="GHC.Utils.Encoding.html#utf8DecodeChar"><span class="hs-identifier hs-var">utf8DecodeChar</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782833"><span class="hs-identifier hs-var">p'</span></a></span><span>
</span><span id="line-385"></span><span>        </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; String -&gt; Ptr Word8 -&gt; IO String
</span><a href="#local-6989586621680782843"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782837"><span class="hs-identifier hs-var">buf0</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782836"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782832"><span class="hs-identifier hs-var">c</span></a></span><span class="annot"><span class="annottext">Char -&gt; ShowS
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782835"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782833"><span class="hs-identifier hs-var">p'</span></a></span><span>
</span><span id="line-386"></span><span>
</span><span id="line-387"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-388"></span><span class="hs-comment">-- Parsing integer strings in various bases</span><span>
</span><span id="line-389"></span><span class="annot"><a href="GHC.Data.StringBuffer.html#parseUnsignedInteger"><span class="hs-identifier hs-type">parseUnsignedInteger</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span class="hs-glyph">-&gt;</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span>
</span><span id="line-390"></span><span id="parseUnsignedInteger"><span class="annot"><span class="annottext">parseUnsignedInteger :: StringBuffer -&gt; Int -&gt; Integer -&gt; (Char -&gt; Int) -&gt; Integer
</span><a href="GHC.Data.StringBuffer.html#parseUnsignedInteger"><span class="hs-identifier hs-var hs-var">parseUnsignedInteger</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.StringBuffer.html#StringBuffer"><span class="hs-identifier hs-type">StringBuffer</span></a></span><span> </span><span id="local-6989586621680782831"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782831"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680782830"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782830"><span class="hs-identifier hs-var">cur</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680782829"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782829"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span id="local-6989586621680782828"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782828"><span class="hs-identifier hs-var">radix</span></a></span></span><span> </span><span id="local-6989586621680782827"><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="#local-6989586621680782827"><span class="hs-identifier hs-var">char_to_int</span></a></span></span><span>
</span><span id="line-391"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO Integer -&gt; Integer
forall a. IO a -&gt; a
</span><a href="GHC.Utils.IO.Unsafe.html#inlinePerformIO"><span class="hs-identifier hs-var">inlinePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO Integer -&gt; Integer) -&gt; IO Integer -&gt; Integer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO Integer) -&gt; IO Integer
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier hs-var">withForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621680782831"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO Integer) -&gt; IO Integer)
-&gt; (Ptr Word8 -&gt; IO Integer) -&gt; IO Integer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680782825"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782825"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; IO Integer
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Integer -&gt; IO Integer) -&gt; Integer -&gt; IO Integer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-keyword">let</span><span>
</span><span id="line-392"></span><span>    </span><span id="local-6989586621680782814"><span class="annot"><span class="annottext">go :: Int -&gt; Integer -&gt; Integer
</span><a href="#local-6989586621680782814"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680782813"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782813"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span id="local-6989586621680782812"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782812"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782813"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782829"><span class="hs-identifier hs-var">len</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782812"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-393"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(Char, Int) -&gt; Char
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8 -&gt; (Char, Int)
</span><a href="GHC.Utils.Encoding.html#utf8DecodeChar"><span class="hs-identifier hs-var">utf8DecodeChar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782825"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782830"><span class="hs-identifier hs-var">cur</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782813"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-394"></span><span>               </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'_'</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Integer -&gt; Integer
</span><a href="#local-6989586621680782814"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782813"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782812"><span class="hs-identifier hs-var">x</span></a></span><span>    </span><span class="hs-comment">-- skip &quot;_&quot; (#14473)</span><span>
</span><span id="line-395"></span><span>               </span><span id="local-6989586621680782811"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782811"><span class="hs-identifier hs-var">char</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Integer -&gt; Integer
</span><a href="#local-6989586621680782814"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782813"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782812"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680782828"><span class="hs-identifier hs-var">radix</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Integer
forall a. Integral a =&gt; a -&gt; Integer
</span><a href="../../base/src/GHC.Real.html#toInteger"><span class="hs-identifier hs-var">toInteger</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="#local-6989586621680782827"><span class="hs-identifier hs-var">char_to_int</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782811"><span class="hs-identifier hs-var">char</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-396"></span><span>  </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Integer -&gt; Integer
</span><a href="#local-6989586621680782814"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span>
</span><span id="line-397"></span></pre></body></html>